package com.ruoyi.web.controller.student_club.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.student_club.dto.LeaveMessageDto;
import com.ruoyi.student_club.service.IClubService;
import com.ruoyi.student_club.service.IFirstMessageService;
import com.ruoyi.student_club.service.IFirstPosterService;
import com.ruoyi.student_club.vo.app.ClubRecommendVo;
import com.ruoyi.student_club.vo.app.FirstMessageVo;
import com.ruoyi.student_club.vo.app.FirstPagePosterVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author lin
 * @Date 2022/1/29 23:23
 */
@RestController
@RequestMapping("/firstPage")
public class FirstPageController {

    @Resource
    private IFirstPosterService posterService;

    @Resource
    private IClubService clubService;

    @Resource
    private IFirstMessageService messageService;

    /**
     * 获取首页轮播图
     * @return
     */
    @GetMapping("/getFirstPosterList")
    public AjaxResult posterList(){
        List<FirstPagePosterVo> firstPagePosterVoList = posterService.showPoster();
        return AjaxResult.success(firstPagePosterVoList);
    }

    /**
     * 获取首页推荐的社团
     * @return
     */
    @GetMapping("/getClubRecommendList")
    public AjaxResult getClubRecommend(){
        List<ClubRecommendVo> clubRecommendList = clubService.getClubRecommendList();
        return AjaxResult.success(clubRecommendList);
    }

    /**
     * 获取首页留言列表
     * @return
     */
    @GetMapping("/getFistMessageList")
    public AjaxResult getFirstMessageList(){
        List<FirstMessageVo> firstMessageList = messageService.getFirstMessageList();
        return AjaxResult.success(firstMessageList);
    }

    /**
     * 发布留言
     * @return
     */
    @PostMapping("/saveLeaveMessage")
    public AjaxResult saveLeaveMessage(@RequestBody LeaveMessageDto dto){
        messageService.saveLeaveMessage(dto);
        return AjaxResult.success();
    }

}
